/*
struct ListNode {
	int val;
	struct ListNode *next;
	ListNode(int x) :
			val(x), next(NULL) {
	}
};*/
class Solution {
public:
	ListNode* FindFirstCommonNode(ListNode* pHead1, ListNode* pHead2) {
		set<ListNode*> t;
		ListNode* cur = pHead1;
		while (cur)
		{
			t.insert(cur);
			cur = cur->next;
		}
		cur = pHead2;
		while (cur)
		{
			if (t.count(cur))
			{
				return cur;
			}
			cur = cur->next;
		}
		return nullptr;

	}
};
